package reflect;

import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public ReflectDemo3() throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException {
    }

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Person p = new Person("张三");
        System.out.println(p);
        Class cls = Class.forName("reflect.Person");
        Constructor constructor = cls.getConstructor(String.class);
        Object obj = constructor.newInstance("李四");
        System.out.println(obj);


        Constructor constructor1 = cls.getConstructor(String.class, int.class);
        Object obj1 = constructor1.newInstance("王五", 20);
        System.out.println(obj1);


    }
}
